package com.liao.kv.key;

import com.liao.kv.base.BaseDimension;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class ContactDimension extends BaseDimension {

    //数据库主键
    private int id;
    //手机号码
    private String telephone;
    //姓名
    private String name;

    public ContactDimension() {
        super();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ContactDimension(String telephone, String name) {
        super();
        this.telephone = telephone;
        this.name = name;
    }

    public int compareTo(BaseDimension o) {
        ContactDimension other=(ContactDimension) o;
        return telephone.compareTo(other.telephone);
    }

    public void write(DataOutput out) throws IOException {
        out.writeUTF(name);
        out.writeUTF(telephone);
    }

    public void readFields(DataInput in) throws IOException {
        this.name= in.readUTF();
        this.telephone= in.readUTF();
    }

    @Override
    public String toString() {
        return "ContactDimension{" +
                "id=" + id +
                ", telephone='" + telephone + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
